#!/bin/bash
set -e
cd ${JM_SHARE_DIR}

#配置Rclone的配置文件，即连接上COS
echo "进入rclone配置文件"
rclone config
echo "新建一个remote连接"
n

echo "输入新建连接配置名称"
${JIANMU_CONFIG_NAME}

echo "输入存储对象类型"
5

echo "选择腾讯云COS"
16

echo "选择env_auth"
1

echo "输入access_key_id"
${JIANMU_ACCESS_KEY_ID}

echo "输入secret_access_key"
${JIANMU_SECRET_ACCESS_KEY}

echo "选择地域"
case ${JIANMU_ENDPOINT} in
	"BEIJING") 1;;
	"NANJING") 2;;
	"SHANGHAI") 3;;
	"GUANGZHOU") 4;;
	"CHENGDU") 6;;
	"CHONGQING") 7;;
	"HONGKONG") 8;;
	*) echo "没有相关end_point，请重试";;

echo "输入ACL"
6

echo "输入storage_class"
1

echo "是否进行高级配置"
n

echo "新建config文件成功"
y

echo "退出配置"
q

rclone mkdir ${JIANMU_CONFIG_NAME}:${JIANMU_BUCKET}-${JIANMU_APPID}
rclone copy ${JIANMU_FILE_PATH} ${JIANMU_CONFIG_NAME}:${JIANMU_BUCKET}-${JIANMU_APPID}


